package com.bdqn.schoolcms.utils;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <功能简要><br>
 * <>
 *
 * @author ：yjw
 * @date ：Created in 2021/4/4 19:14
 * @description：获取地址工具类
 * @modified By：
 * @version: 1.0.0
 */
public class AddressUtils {
    private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);

    public static final String IP_URL = "http://ip.taobao.com/service/getIpInfo.php";

    public static String getRealAddressByIP(String ip) {
        String address = "XX XX";
        // 内网不查询
        if (IpUtils.internalIp(ip)) {
            return "内网IP";
        }
        //查询ip地址
        String rspStr = AddressCore.getAddress(ip);
        if (StringUtils.isEmpty(rspStr)) {
            log.error("获取地理位置异常 {}", ip);
            return address;
        }

        return rspStr;
    }

}
